package com.wm.wmim.server.service.wsmessage;

import com.wm.wmim.common.bo.resp.CommonBizRespBo;
import com.wm.wmim.server.dto.bo.WsMessageBO;
import com.wm.wmim.server.dto.bo.req.PrivateChatOnMessageReqBodyBO;
import com.wm.wmim.server.dto.bo.resp.PrivateChatOnMessageRespBodyBO;
import com.wm.wmim.server.enums.WsMessageTypeEnum;
import com.wm.wmim.server.service.ChatService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author weiming
 * @date 2024/8/29 20:51
 * @description
 */
@Service
public class WsClientAckHandleService extends AbstractWebSocketMessageHandleService<PrivateChatOnMessageReqBodyBO, WsMessageBO<PrivateChatOnMessageRespBodyBO>> {


    @Resource
    private ChatService chatService;

    @Override
    protected WsMessageBO<PrivateChatOnMessageRespBodyBO> process(PrivateChatOnMessageReqBodyBO reqVO) {
        CommonBizRespBo<PrivateChatOnMessageRespBodyBO> resp = chatService.sendPrivateMessage(reqVO);
        WsMessageBO messageBO = new WsMessageBO();
        messageBO.setMessageType(WsMessageTypeEnum.ACK.getCode());
        messageBO.setMessageBody(resp.getData());
        return messageBO;
    }



    @Override
    protected WsMessageTypeEnum getMessageType() {
        return WsMessageTypeEnum.PRIVATE_CHAT;
    }
}
